package cn.bd13.swagger.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName：TestController
 * Package:cn.bd13.swagger.controller
 * Description:
 *
 * @Date:2020/5/12 21:22
 * @Author:zhangqiang@kgc.cn
 */
@RestController
@Api(tags = "这是TestController中的内容")
public class TestController {

    @ApiOperation(value = "这是打招呼的方法")
    @GetMapping("/hello")
    public String hello(){
        System.out.println("hello swagger !");
        return "hello";
    }

    @ApiOperation(value = "这是判断姓名的方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name" ,example = "hhh" ,required = true)
    })
    @ApiResponses({
            @ApiResponse(code = 501 ,message = "数据库操作有误"),
            @ApiResponse(code = 502 ,message = "JAVA操作有误"),
            @ApiResponse(code = 503 ,message = "REDIS操作有误")
    })
    @GetMapping("/checkName")
    public String checkName(String name){
        if (name.equals("admin")){
            return "hello admin !";
        }
        else {
            return "wrong name !";
        }
    }
}
